﻿using UnityEngine;
using System.Collections;
using PureMVC.Patterns;
using PureMVC.Interfaces;
using OrderSystem;
using System.Collections.Generic;

public class ClientCallWaiterCommand :SimpleCommand
{
    public override void Execute(INotification notification)
    {
      
        ClientItem client = notification.Body as ClientItem;
        
        if (client.state.Equals(E_ClientState.Idle)|| client.state.Equals(E_ClientState.Pay))
        {

            OrderProxy orderProxy = Facade.RetrieveProxy(OrderProxy.NAME) as OrderProxy;

            Order order = new Order(client, new List<MenuItem>());
            orderProxy.AddOrder(order);

            WaiterProxy waiterProxy = Facade.RetrieveProxy(WaiterProxy.NAME) as WaiterProxy;
            WaiterItem waiter = waiterProxy.serverMenuToClient(client, order);
  
            SendNotification(OrderSystemEvent.UPDATE_WAITER_VIEW, waiterProxy.Waiters);
        } 
        else
        {
            Debug.Log("已经下单");
        }
    }
}
